package JUnit;

import static org.junit.Assert.*;

import java.io.IOException;
import java.util.Calendar;

import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;

import org.junit.Test;
import org.xml.sax.SAXException;

import entity.Goal;
import entityManager.GoalManager;

public class GoalManagerTest {
/*
	@Test
	public void testGoalManager() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetSavingPot() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetToSaveAmt() {
		fail("Not yet implemented");
	}

	@Test
	public void testSetSavingPot() {
		fail("Not yet implemented");
	}

	@Test
	public void testDepositSavingPot() {
		fail("Not yet implemented");
	}

	@Test
	public void testWithdrawSavingPot() {
		fail("Not yet implemented");
	}

	@Test
	public void testSetToSaveAmt() {
		fail("Not yet implemented");
	}

	@Test
	public void testLoadAll() {
		fail("Not yet implemented");
	}

	@Test
	public void testAdd() {
		fail("Not yet implemented");
	}

	@Test
	public void testRemove() {
		fail("Not yet implemented");
	}

	@Test
	public void testUpdate() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetById() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetAll() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetActiveGoal() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetByDate() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetByKeyword() {
		fail("Not yet implemented");
	}

	@Test
	public void testCalSavedAmount() {
		fail("Not yet implemented");
	}

	@Test
	public void testCalculateSumOfGoal() {
		fail("Not yet implemented");
	}

	@Test
	public void testDeactivateAllGoal() {
		fail("Not yet implemented");
	}

	@Test
	public void testCheckUpdate() {
		fail("Not yet implemented");
	}

	@Test
	public void testActivateDisableGoal() {
		fail("Not yet implemented");
	}

	@Test
	public void testHandleGoal() {
		fail("Not yet implemented");
	}
*/
	@Test
	public void testCalculateSumOfGoal() throws TransformerConfigurationException, InstantiationException, IllegalAccessException, JAXBException, ParserConfigurationException, SAXException, IOException, TransformerException {
         GoalManager gm = new GoalManager();
		
		
		Calendar today = Calendar.getInstance();
		today.set(2013, Calendar.MARCH, 1);
		Calendar yester = Calendar.getInstance(); 
		yester.set(2013, Calendar.JANUARY, 3);

		Goal Temp1 = new Goal("123", today, Calendar.getInstance(), 100, 0, null, false, false);
		
		Goal Temp2 = new Goal("23", yester, Calendar.getInstance(), 2300, 0, null, false, false);
		gm.add(Temp1);
		gm.add(Temp2);
	
	
		
		assertEquals(gm.CalSavedAmount(gm.getAll()), (gm.getAll().get(0).getAmountAchieved()+ gm.getAll().get(1).getAmountAchieved() ), 0.0);
		
		
	}
	
	@Test
	public void testSortListAscendingDate() throws TransformerConfigurationException, InstantiationException, IllegalAccessException, JAXBException, ParserConfigurationException, SAXException, IOException, TransformerException {
		GoalManager gm = new GoalManager();
		
		
		Calendar today = Calendar.getInstance();
		today.set(2013, Calendar.MARCH, 1);
		Calendar yester = Calendar.getInstance(); 
		yester.set(2013, Calendar.JANUARY, 3);

		Goal Temp1 = new Goal("123", today, Calendar.getInstance(), 100, 0, null, false, false);
		
		Goal Temp2 = new Goal("23", yester, Calendar.getInstance(), 100, 0, null, false, false);
		gm.add(Temp1);
		gm.add(Temp2);
		
		gm.SortListAscendingDate(gm.getAll());
		assertEquals(gm.getAll().get(0).getName(), Temp2.getName());
	}

}
